import { defineStore } from 'pinia'

export default defineStore('user', {
  state: () => ({
    userInfo: JSON.parse(localStorage.getItem('userInfo') || '{}') as any,
    permissionCodes: JSON.parse(localStorage.getItem('permission') || '[]') as Array<string>
  }),

  actions: {
    async getPermissionCodes () {
      if (this.permissionCodes.length) {
        return this.permissionCodes
      }
      return []
    }
  }
})
